package com.aaa.sbms.service;

import com.aaa.sbms.dao.EmpCheckInDao;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class EmpCheckInServiceImpl implements EmpCheckInService {

    @Autowired
    private EmpCheckInDao empCheckInDao;

    @Override
    public Map getList(Map map) {
        int pageNo = Integer.valueOf(map.get("pageNo")+"");
        int pageSize = Integer.valueOf(map.get("pageSize")+"");
        PageHelper.startPage(pageNo,pageSize);
        //PageHelper.offsetPage(pageNo,pageSize);
        PageInfo<Map> pageInfo = new PageInfo<Map>(empCheckInDao.list(map));
        Map rmap  = new HashMap();
        rmap.put("total",pageInfo.getTotal());
        rmap.put("page",pageInfo.getList());
        return rmap;
    }

    @Override
    public int updateIng(Integer userid) {
        return empCheckInDao.updateIng(userid);
    }

    @Override
    public List<Map> getFloor(Map map) {
        return empCheckInDao.floorList(map);
    }

    @Override
    public List<Map> getRoom(Map map) {
        return empCheckInDao.roomList(map);
    }

    @Override
    public int delBedCount(Map map) {
        return empCheckInDao.delBedCount(map);
    }

    @Override
    public int add(Map map) {
        map.put("HOUSEID","男".equals(map.get("sex"))?1:2);
        return empCheckInDao.insert(map);
    }
}
